﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T15OOP2
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                {
                    //Product p = new Product();// 错误：抽象类不能实例化
                    Book book = new Book();//具有默认或无参构造函数能正确初始化，无需显示使用
                    book.Name = "天龙八部";
                    book.Price = 30.0M;
                    book.Isbn = "9343431111431";
                    book.Intro = "江湖传奇";
                    book.Show();
                    book.ShowDetail();
                    //book = null;//谨慎使用，可以提高内容使用效率
                    Console.WriteLine("=======================================");
                    Digital digital = new Digital();
                    digital.Name = "蓝牙音箱";
                    digital.Price = 399M;
                    digital.Barcode = "1120303403";

                    Action buy = new Action();
                    buy.Buy(book);
                    buy.Buy(digital);

                    buy.Show();
                }
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("输入信息有误 ！");
            }
            catch (Exception)
            {
                Console.WriteLine("其他错误");
            }


            //内存垃圾回收
            System.GC.Collect();

            Console.ReadKey();

        }
    }
}